USE [DTP]
GO

/****** Object:  Table [dbo].[t_AccidentCards]    Script Date: 11/26/2010 13:44:43 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[t_VehicleCards](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	
	 [enginNumber] [nvarchar](50) NULL,
        [bodyNumber] [nvarchar](50) NULL,
        [chassisNumber] [nvarchar](50) NULL,
        [creationYear] [int] NULL, 
        [passangersAmmount] [int] NULL, 
        [trailerAmmount] [int] NULL, 
        [carIdNumber] [nvarchar](50) NULL,
        [carRegistrationCardNumber] [nvarchar](50) NULL,        
        [vehicleNumber] [nvarchar](1024) NULL,
        
        [escape] [int] NULL,
        [vehicleType] [int] NULL,       
        [color] [int] NULL,
        [malfunctions] [int] NULL,
        [factoryCode] [int] NULL,
        [modelCode] [int] NULL,
        [wheelAndDrive] [int] NULL,        
        [damagePlaces] [int] NULL,        
        [registrationRegion] [int] NULL,        
        [organizationType] [int] NULL,
        [ownershipType] [int] NULL,
        [organizationName] [int] NULL,
        [haveLicence] [int] NULL,
        [inSearch] [int] NULL,
	[Deleted] [bit] NOT NULL,
	

 CONSTRAINT [PK_VehicleCards] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_escape] FOREIGN KEY([escape])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_escape]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_vehicleType] FOREIGN KEY([vehicleType])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_vehicleType]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_color] FOREIGN KEY([color])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_color]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_malfunctions] FOREIGN KEY([malfunctions])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_malfunctions]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_factoryCode] FOREIGN KEY([factoryCode])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_factoryCode]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_modelCode] FOREIGN KEY([modelCode])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_modelCode]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_wheelAndDrive] FOREIGN KEY([wheelAndDrive])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_wheelAndDrive]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_damagePlaces] FOREIGN KEY([damagePlaces])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_damagePlaces]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_registrationRegion] FOREIGN KEY([registrationRegion])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_registrationRegion]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_organizationType] FOREIGN KEY([organizationType])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_organizationType]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_organizationName] FOREIGN KEY([organizationName])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_organizationName]
GO
ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_haveLicence] FOREIGN KEY([haveLicence])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_haveLicence]
GO

ALTER TABLE [dbo].[t_VehicleCards]  WITH CHECK ADD  CONSTRAINT [FK_inSearch] FOREIGN KEY([inSearch])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_VehicleCards] CHECK CONSTRAINT [FK_inSearch]
GO


ALTER TABLE [dbo].[t_VehicleCards] ADD  DEFAULT ((0)) FOR [Deleted]
GO


